﻿using System.Data;
using System.Data.SqlClient;

namespace VirtualTournaments.DataAccess.SqlServer.Connections
{
#if DEBUG
	public 
#else
	internal
#endif
	sealed class ConnectionManager
	{
		private static IDbConnection _connection = null;
		private static readonly object _connectionLocker = new object();

		public static IDbConnection GetConnection()
		{
			if (_connection == null)
			{
				lock (_connectionLocker)
				{
					if (_connection == null)
					{
						_connection = new SqlConnection(Properties.Settings.Default.ConnectionString);
					}
				}
			}
			return _connection;
		}
	}
}
